#!/bin/bash

#modify the path to correct one
jrPATH="~/jrmiddleware"
PlayerJAUS_DemoPATH="~/amrl-ros-pkg/PlayerJAUS_Demo"

if [[ "$(uname)" = "Darwin" ]]; then
say "Start JAUS Demo, Running Stage"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp1.sh
echo cd $PlayerJAUS_DemoPATH       >> ~/temp1.sh
echo cd JAUS_Stage3                >> ~/temp1.sh
echo player JAUS.cfg               >> ~/temp1.sh
chmod +x ~/temp1.sh
osascript -e 'tell application "Terminal" to do script "./temp1.sh"'  
sleep 5
#rm ~/temp.sh  

say "Start junior R T E"
#generate a script for juniorRTE and run it
echo "#!/bin/bash"             >  ~/temp2.sh
echo cd $jrPATH                >> ~/temp2.sh
echo cd bin                    >> ~/temp2.sh
echo ./JuniorRTE jr_config.xml >> ~/temp2.sh
chmod +x ~/temp2.sh
osascript -e 'tell application "Terminal" to do script "./temp2.sh"'  
sleep 5

say "Start Waypoint C O P"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp3.sh
echo cd $PlayerJAUS_DemoPATH       >> ~/temp3.sh
echo ./WaypointCOP                 >> ~/temp3.sh
chmod +x ~/temp3.sh
osascript -e 'tell application "Terminal" to do script "./temp3.sh"'  
sleep 5

say "Start Player JAUS"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp4.sh
echo cd $PlayerJAUS_DemoPATH       >> ~/temp4.sh
echo ./PlayerJAUS                  >> ~/temp4.sh
chmod +x ~/temp4.sh
osascript -e 'tell application "Terminal" to do script "./temp4.sh"'  
sleep 5
rm ~/temp?.sh  
  
  
  
else
  espeak "This is Linux"
#gnome-terminal --title=gps_gps_vel --zoom=0.6 --geometry=80x24+800+500 -x sh -c 'rostopic echo gps/vel'  
  
espeak "Start jaws Demo, Running Stage"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp1.sh
echo cd $PlayerJAUS_DemoPATH          >> ~/temp1.sh
echo cd JAUS_Stage3               >> ~/temp1.sh
echo player JAUS_linux.cfg               >> ~/temp1.sh
chmod +x ~/temp1.sh
gnome-terminal --title=PlayerStage -x sh -c 'cd ~ && ./temp1.sh' 
sleep 5
#rm ~/temp.sh  

espeak "Start junior R T E"
#generate a script for juniorRTE and run it
echo "#!/bin/bash"             >  ~/temp2.sh
echo cd $jrPATH                >> ~/temp2.sh
echo cd bin                    >> ~/temp2.sh
echo ./JuniorRTE jr_config.xml >> ~/temp2.sh
chmod +x ~/temp2.sh
gnome-terminal --title=JuniorRTE -x sh -c 'cd ~ && ./temp2.sh' 
sleep 5

espeak "Start Waypoint C O P"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp3.sh
echo cd $PlayerJAUS_DemoPATH          >> ~/temp3.sh
echo ./WaypointCOP                 >> ~/temp3.sh
chmod +x ~/temp3.sh
gnome-terminal --title=WaypointCOP -x sh -c 'cd ~ && ./temp3.sh' 
sleep 5

espeak "start player jaws"
#generate a script for stage and run it
echo "#!/bin/bash"                 >  ~/temp4.sh
echo cd $PlayerJAUS_DemoPATH          >> ~/temp4.sh
echo ./PlayerJAUS                  >> ~/temp4.sh
chmod +x ~/temp4.sh
gnome-terminal --title=PlayerJAUS -x sh -c 'cd ~ && ./temp4.sh' 
sleep 5
rm ~/temp?.sh  
  
  
  
  
  
  
  
  
  
  
  
  
  
fi
